<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. -->
<Project>
  <Target Name="_WorkloadTelemetry"
          Condition="'$(_MonoWorkloadTargetsMobile)' == 'true' and '$(TargetsCurrent)' == 'true'"
          AfterTargets="Publish"
          DependsOnTargets="_WorkloadGatherTelemetryData">

    <ItemGroup>
      <WorkloadPublishProperties Include="TargetPlatformIdentifier" Value="$(TargetPlatformIdentifier)" />
      <WorkloadPublishProperties Include="RuntimeIdentifier" Value="$(RuntimeIdentifier)" />
      <WorkloadPublishProperties Include="BlazorWasm" Value="$(_WorkloadUsesBlazorWasm)" />
      <WorkloadPublishProperties Include="WasmSDK" Value="$(_WorkloadUsesWasmSDK)" />
      <WorkloadPublishProperties Include="UsesMaui" Value="$(UseMaui)" />
      <WorkloadPublishProperties Include="UsesMobileSDKOnly" Value="$(_WorkloadUsesMobileSDKOnly)" />
      <WorkloadPublishProperties Include="UsesOtherMobileSDK" Value="$(_WorkloadUsesOther)" />
      <WorkloadPublishProperties Include="MonoAOT" Value="$(_WorkloadUsesMonoAOT)" />
      <WorkloadPublishProperties Include="NativeAOT" Value="$(_WorkloadUsesNativeAOT)" />
      <WorkloadPublishProperties Include="Interp" Value="$(_WorkloadUsesInterpreter)" />
      <WorkloadPublishProperties Include="LibraryMode" Value="$(_WorkloadUsesLibraryMode)" />
      <WorkloadPublishProperties Include="HybridGlobalization" Value="$(HybridGlobalization)" />
      <WorkloadPublishProperties Include="ResolvedRuntimePack" Value="$(_MonoWorkloadRuntimePackPackageVersion)" />
      <WorkloadPublishProperties Include="StripILAfterAOT" Value="$(_WorkloadUsesStripILAfterAOT)" />
    </ItemGroup>

    <AllowEmptyTelemetry EventName="WorkloadPublishProperties" EventData="@(WorkloadPublishProperties)" />
  </Target>

  <Target Name="_WorkloadGatherTelemetryData">
    <PropertyGroup>
      <_WorkloadUsesBlazorWasm>$(UsingMicrosoftNETSdkBlazorWebAssembly)</_WorkloadUsesBlazorWasm>
      <_WorkloadUsesWasmSDK>$(UsingMicrosoftNETSdkWebAssembly)</_WorkloadUsesWasmSDK>
      <_WorkloadUsesMonoAOT>$(RunAOTCompilation)</_WorkloadUsesMonoAOT>
      <!-- _RunAotCompiler is defined in xamarin ios targets -->
      <_WorkloadUsesMonoAOT Condition="'$(_WorkloadUsesMonoAOT)' == '' and '$(PublishAot)' != 'true' and ('$(TargetPlatformIdentifier)' == 'maccatalyst' or '$(TargetPlatformIdentifier)' == 'ios' or '$(TargetPlatformIdentifier)' == 'tvos')">$(_RunAotCompiler)</_WorkloadUsesMonoAOT>
      <_WorkloadUsesNativeAOT>$(PublishAot)</_WorkloadUsesNativeAOT>
      <_WorkloadUsesInterpreter>$(MonoForceInterpreter)</_WorkloadUsesInterpreter>
      <_WorkloadUsesInterpreter Condition="'$(_WorkloadUsesInterpreter)' == '' and '$(UseInterpreter)' == 'true'">true</_WorkloadUsesInterpreter>
      <_WorkloadUsesInterpreter Condition="'$(_WorkloadUsesInterpreter)' == '' and '$(RunAOTCompilation)' != 'true' and ('$(_WorkloadUsesBlazorWasm)' == 'true' or '$(_WorkloadUsesWasmSDK)' == 'true')">true</_WorkloadUsesInterpreter>
      <_WorkloadUsesLibraryMode Condition="'$(NativeLib)' != '' and ('$(_WorkloadUsesMonoAOT)' == 'true' or '$(_WorkloadUsesNativeAOT)' == 'true')">true</_WorkloadUsesLibraryMode>
      <_WorkloadUsesStripILAfterAOT Condition="'$(WasmStripILAfterAOT)' == 'true' or '$(AndroidStripILAfterAOT)' == 'true'">true</_WorkloadUsesStripILAfterAOT>
    </PropertyGroup>

    <PropertyGroup>
      <_WorkloadUsesOther Condition="'$([System.IO.Path]::GetFileName(&quot;%(ReferencePath.Identity)&quot;).ToLowerInvariant())' == 'avalonia.dll'">true</_WorkloadUsesOther>
      <_WorkloadUsesOther Condition="'$([System.IO.Path]::GetFileName(&quot;%(ReferencePath.Identity)&quot;).ToLowerInvariant())' == 'uno.dll'">true</_WorkloadUsesOther>
      <_WorkloadUsesMobileSDKOnly Condition="'$(RuntimeIdentifier)' != 'browser-wasm' and '$(UseMaui)' != 'true' and '$(_WorkloadUsesOther)' != 'true'">true</_WorkloadUsesMobileSDKOnly>
    </PropertyGroup>
  </Target>
</Project>
